package GUI;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

import Listeners.LoginListener;
import Model.ConferenceManager;

/**
 * JPanel that displays program splash screen and allows
 * users to log in to the Conference Wizard.
 * 
 * @author Paul Schultz(ps87@uw.edu)
 * @version 11/24/2012
 */
@SuppressWarnings("serial")
public class LoginPanel extends JPanel{
	
	private static final JLabel WELCOME_MESSAGE = new JLabel("Welcome to Conference Wizard");
	
	/**
	 * Constructs a LoginPanel allowing users to log-in.
	 * 
	 * @param the_manager The ConferenceManager that holds conference data.
	 * @param master_frame Reference to master frame of the application.
	 */
	public LoginPanel(final ConferenceManager the_manager, final ConferenceWizardFrame master_frame) 
	{
	  
  		super();
  		setLayout(new BorderLayout());
  		setPreferredSize(new Dimension(800, 600));
  	  setBackground(Color.LIGHT_GRAY);
  	    
  	  WELCOME_MESSAGE.setForeground(Color.BLUE);
  	  WELCOME_MESSAGE.setFont(new Font("PLAIN", Font.BOLD, 38));
  	  WELCOME_MESSAGE.setAlignmentY(CENTER_ALIGNMENT);
  	  JPanel north_panel = new JPanel();
  	  north_panel.setBackground(Color.WHITE);
  	  north_panel.add(WELCOME_MESSAGE);
  	  add(north_panel, BorderLayout.NORTH);
  	  
  	  JPanel center_panel = new JPanel();
  	  //center_panel.setLayout(new BoxLayout(center_panel, BoxLayout.Y_AXIS));
  	  center_panel.add(Box.createRigidArea(new Dimension(0, 300)));
  	  
  	  JPanel prompt_panel = new JPanel();
  	  prompt_panel.setLayout(new BoxLayout(prompt_panel, BoxLayout.Y_AXIS));
  	  prompt_panel.setAlignmentY(CENTER_ALIGNMENT);
  	  prompt_panel.setBackground(Color.WHITE);
  	  //prompt_panel.setPreferredSize(new Dimension(300, 50));
  	  
  	  JLabel login_label = new JLabel("Please Login Below...");
  	  login_label.setFont(new Font("Plain", Font.PLAIN, 20));
  	  login_label.setAlignmentY(CENTER_ALIGNMENT);
  	  prompt_panel.add(login_label);
  	  
  	  final JTextField loginField = new JTextField("Username", 20);
  	  loginField.setFont(new Font("Plain", Font.PLAIN, 20));
  	  prompt_panel.add(loginField);
  	  
  	  center_panel.add(prompt_panel);
	    
	    final JButton Login = new JButton(new LoginListener(the_manager, master_frame, loginField));
	    Login.setText("Login");
	 
	    
	    JPanel south_panel = new JPanel();
	    south_panel.setBackground(Color.WHITE);
	    south_panel.setLayout(new BoxLayout(south_panel, BoxLayout.Y_AXIS));
	    south_panel.add(Login);
	    
	    JPanel login_pan = new JPanel();
	    login_pan.setPreferredSize(new Dimension(200,100));
	    login_pan.setBackground(Color.WHITE);
	    login_pan.setAlignmentY(CENTER_ALIGNMENT);
	    login_pan.add(Login);
	    add(login_pan, BorderLayout.SOUTH);
	    
	    center_panel.setBackground(Color.WHITE);
	    center_panel.setAlignmentY(CENTER_ALIGNMENT);
	    add(center_panel, BorderLayout.CENTER);
	}

}
